package com.hopes.bizz.risk.hid.vo;

import com.hopes.bizz.common.core.util.DateUtils;
import com.hopes.bizz.common.core.util.StringUtils;
import com.hopes.bizz.risk.common.constant.enums.RiskFacDicEnum;
import com.hopes.bizz.risk.common.constant.enums.RiskModDictEnum;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.admin.api.resolver.enums.AdminDictEnum;
import com.hopes.boss.admin.api.resolver.enums.SysDictEnum;
import com.hopes.boss.common.entity.BaseLogicEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @author daijie
 * @version 1.0
 * @date 2023/7/27 11:33
 * @Description:
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "隐患检查计划VO")
public class RiskHidCheckPlanVO extends BaseLogicEntity {

    private static final long serialVersionUID = 4328210444020725213L;

    private Long id;

    private String planName;

    private String planNo;

    private String hidCheckListConfigId;

    private String checkObject;

    private Long recorder;

    private String recorderIdCard;

    private String checkPerson;

    private String riskUnitId;

    private Integer pushType;

    private String checkTime;

    private String pushCycle;

    private String pushTime;

    private String pushMonth;

    private String pushWeek;

    private String pushDate;

    private Integer maxHandleHour;

    private Boolean runFlag;

    private Date preExecuteDate;

    private Date nextExecuteDate;

    private String remarks;

    private Long orgId;

    public String getRecorderStr() {
        return DictResolver.getItemLabelByValue(AdminDictEnum.sys_user, this.getRecorder());
    }

    public String getCheckPersonStr() {
        return DictResolver.getItemLabelByValue(AdminDictEnum.sys_user, this.getCheckPerson());
    }

    public String getRunFlagStr() {
        return DictResolver.getItemLabelByValue(SysDictEnum.run_status, this.getRunFlag());
    }

    public String getPreExecuteDateStr() {
        return DateUtils.limitMinute(this.preExecuteDate);
    }

    public String getNextExecuteDateStr() {
        return DateUtils.limitMinute(this.nextExecuteDate);
    }

    public String getRiskUnitIdStr() {
        return DictResolver.getItemLabelByValue(RiskModDictEnum.risk_unit, this.getRiskUnitId());
    }

    public String getPushCycleStr() {
        return DictResolver.getItemLabelByValue(RiskFacDicEnum.push_cycle, this.getPushCycle());
    }

    public String getPushYearStr() {
        return DictResolver.getItemLabelByValue(RiskFacDicEnum.push_cycle_year, this.getPushDate());
    }

    public String getPushMonthStr() {
        return DictResolver.getItemLabelByValue(RiskFacDicEnum.push_cycle_month, this.getPushCycle());
    }

    public String getPushWeekStr() {
        return DictResolver.getItemLabelByValue(RiskFacDicEnum.push_cycle_week, this.getPushCycle());
    }

    public String getPushHourStr() {
        return DictResolver.getItemLabelByValue(RiskFacDicEnum.push_cycle_hour, this.getPushDate());
    }

    public String getHidCheckListConfigIdStr() {
        return DictResolver.getItemLabelByValue(RiskModDictEnum.risk_hid_checklist, this.getHidCheckListConfigId());
    }

    public List<Long> getHidCheckListConfigIdList() {
        List<Long> deptList = new ArrayList<>();
        if (this.hidCheckListConfigId != null) {
            for (String s : this.hidCheckListConfigId.split(StringUtils.COMMA)) {
                deptList.add(Long.parseLong(s));
            }
        }
        return deptList;
    }

    public List<Long> getRiskUnitIdList() {
        List<Long> list = new ArrayList<>();
        if (this.riskUnitId != null) {
            for (String s : this.riskUnitId.split(StringUtils.COMMA)) {
                list.add(Long.parseLong(s));
            }
        }
        return list;
    }

    public List<Long> getPushDateList() {
        List<Long> list = new ArrayList<>();
        if (StringUtils.isNotBlank(this.pushDate)) {
            for (String s : this.pushDate.split(StringUtils.COMMA)) {
                list.add(Long.parseLong(s));
            }
        }
        return list;
    }

    public List<Long> getPushTimeList() {
        List<Long> list = new ArrayList<>();
        if (StringUtils.isNotBlank(this.pushTime)) {
            for (String s : this.pushTime.split(StringUtils.COMMA)) {
                list.add(Long.parseLong(s));
            }
        }
        return list;
    }
}
